package cn.iocoder.yudao.module.biz.controller.admin.homePage;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.biz.service.emergencyReservePlan.BizEmergencyReservePlanService;
import cn.iocoder.yudao.module.biz.service.risk.equipmentInfo.BizEquipmentInfoService;
import cn.iocoder.yudao.module.biz.service.risk.riskInfo.RiskInfoService;
import cn.iocoder.yudao.module.biz.service.staff.BizStaffService;
import cn.iocoder.yudao.module.biz.service.staffCertificate.BizStaffCertificateService;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;


@Api(tags = "管理后台 - 设备")
@RestController
@RequestMapping("/biz/homePage")
@Validated
public class HomePageController {

    @Resource
    private BizStaffService staffService;
    @Resource
    private BizEquipmentInfoService equipmentInfoService;
    @Resource
    private RiskInfoService riskInfoService;
    @Resource
    private BizEmergencyReservePlanService emergencyReservePlanService;
    @Resource
    private BizStaffCertificateService staffCertificateService;

    @GetMapping("/homeCount")
    public CommonResult<Map<String,Long>> homeCount() {
        Long staffCount = staffService.getStaffCount();
        Long certificateCount = staffCertificateService.getStaffCount();
        Long equipmentCount = equipmentInfoService.getEquipmentCount();
        Long riskInfoCount = riskInfoService.getRiskCount();
        Long hidDangerCount = 0L;
        Map<String,Long>  map = new HashMap<>();
        map.put("staffCount",staffCount);
        map.put("certificateCount",certificateCount);
        map.put("equipmentCount",equipmentCount);
        map.put("riskInfoCount",riskInfoCount);
        map.put("hidDangerCount",hidDangerCount);
        return success(map);
    }

    @GetMapping("/getRiskPie")
    public CommonResult<List<Map<String,Object>>> getRiskPie(){
        return success(riskInfoService.getRiskPie());
    }

    @GetMapping("/getEquipmentPie")
    public CommonResult<List<Map<String,Object>>> getEquipmentPie(){
        return success(equipmentInfoService.getEquipmentPie());
    }
    @GetMapping("/getEmergencyHistogram")
    public CommonResult<List<Map<String,Object>>> getEmergencyHistogram(){
        return success(emergencyReservePlanService.getEmergencyHistogram());
    }
}
